(require-package 'yasnippet)
(yas-global-mode)
(require-package 'company)
(add-hook 'after-init-hook 'global-company-mode)
;; 自动补全配置
(setq company-minimum-prefix-length 2 ;; 输入几个字符开始补全
      company-idle-delay 0.2 ;; 自动补全延时
      company-require-match nil ;;可以输入不符合补全的字符,设置为t只能输入匹配自动补全提供的内容
      company-show-numbers t)
(global-set-key [(control tab)] 'company-complete-common)
(global-set-key (kbd "C-c <tab>") 'company-yasnippet)

;; 定义ccmode使用的自动补全后端
(defun lugg/company-cc-mode ()
  (make-variable-buffer-local 'company-backends);; 将company-backends设置为buffer-local变量
  (setq company-backends '(company-c-headers company-files (company-clang company-yasnippet) company-dabbrev-code)))
(add-hook 'c-mode-hook 'lugg/company-cc-mode)
(add-hook 'c++-mode-hook 'lugg/company-cc-mode)

;; 定义cmake-mode使用的自动补全后端
(defun lugg/company-cmake-mode ()
  (make-variable-buffer-local 'company-backends);; 将company-backends设置为buffer-local变量
  (setq company-backends '(company-cmake company-files)))
(add-hook 'cmake-mode-hook 'lugg/company-cmake-mode)

;; 定义org-mode使用的自动补全后端
(defun lugg/company-org-mode ()
  (make-variable-buffer-local 'company-backends);; 将company-backends设置为buffer-local变量
  (setq company-backends '(company-files)))
(add-hook 'org-mode-hook 'lugg/company-org-mode)

;; 添加doxymacs支持
;; C-c d f 插入下一行函数的doxygen注释
;; C-c d i 插入本文件的doxygen注释
;; C-c d ; 插入当前成员的doxygen注释
;; C-c d s 插入单行的doxygen注释
(require 'doxymacs)
(add-hook 'js2-mode-hook 'doxymacs-mode)
;(add-hook 'c-mode-hook 'doxymacs-mode)
;(add-hook 'c++-mode-hook 'doxymacs-mode)
(add-hook 'c-mode-common-hook 'doxymacs-mode)
(add-hook 'c++-mode-common-hook 'doxymacs-mode)

(provide 'init-company)
